//#include <QObject>
#include "geomSetupRectangle.h"

geomSetupRectangle::geomSetupRectangle()
{
    //QString *lenUnit = new QString();
    //*lenUnit = "mm";
    QString lenUnit = "mm";
    //QString *degUnit = new QString();
    //*degUnit = "deg";
    QString degUnit = "deg";

    tb_build = new QToolButton();
    tb_build->setText("构建");
    tb_build->setIcon(QIcon(":/Geometry/resources/Geometry/buildShape.png"));
    tb_build->setIconSize(QSize(20, 20));
    tb_build->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    tb_build->setAutoRaise(true);
    connect(tb_build, &QToolButton::clicked, this, &geomSetupRectangle::build);

    label_size = new QLabel();
    label_size->setText("尺寸");
    label_size->setStyleSheet("background-color: #B9D1ED;");
    label_a = new QLabel();
    label_a->setText("长：");
    lineEdit_a = new QLineEdit();
    label_a_unit = new QLabel();
    label_a_unit->setText(lenUnit);
    label_b = new QLabel();
    label_b->setText("宽：");
    lineEdit_b = new QLineEdit();
    label_b_unit = new QLabel();
    label_b_unit->setText(lenUnit);

    label_pos = new QLabel();
    label_pos->setText("位置");
    label_pos->setStyleSheet("background-color: #B9D1ED;");
    label_x = new QLabel();
    label_x->setText("x：");
    lineEdit_x = new QLineEdit();
    label_x_unit = new QLabel();
    label_x_unit->setText(lenUnit);
    label_y = new QLabel();
    label_y->setText("y：");
    lineEdit_y = new QLineEdit();
    label_y_unit = new QLabel();
    label_y_unit->setText(lenUnit);

    label_rotate = new QLabel();
    label_rotate->setText("旋转");
    label_rotate->setStyleSheet("background-color: #B9D1ED;");
    label_cbox = new QLabel();
    label_cbox->setText("基准点：");
    cbox = new QComboBox();
    cbox->addItem(QString("中心"));
    cbox->addItem(QString("角点"));
    label_rotate_deg = new QLabel();
    label_rotate_deg->setText("角度：");
    lineEdit_rotate_deg = new QLineEdit();
    label_rotate_deg_unit = new QLabel();
    label_rotate_deg_unit->setText(degUnit);

    vSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
    int i = 0;
    gl->addWidget(tb_build, i, 0, 1, 2);
    // size
    gl->addWidget(label_size,   ++i, 0, 1, 3);
    gl->addWidget(label_a,      ++i, 0, 1, 1);
    gl->addWidget(lineEdit_a,   i,   1, 1, 1);
    gl->addWidget(label_a_unit, i,   2, 1, 1);
    gl->addWidget(label_b,      ++i, 0, 1, 1);
    gl->addWidget(lineEdit_b,   i,   1, 1, 1);
    gl->addWidget(label_b_unit, i,   2, 1, 1);
    // position
    gl->addWidget(label_pos,    ++i, 0, 1, 3);
    gl->addWidget(label_x,      ++i, 0, 1, 1);
    gl->addWidget(lineEdit_x,   i,   1, 1, 1);
    gl->addWidget(label_x_unit, i,   2, 1, 1);
    gl->addWidget(label_y,      ++i, 0, 1, 1);
    gl->addWidget(lineEdit_y,   i,   1, 1, 1);
    gl->addWidget(label_y_unit, i,   2, 1, 1);
    // rotate
    gl->addWidget(label_rotate,          ++i, 0, 1, 3);
    gl->addWidget(label_cbox,            ++i, 0, 1, 1);
    gl->addWidget(cbox,                    i, 1, 1, 2);
    gl->addWidget(label_rotate_deg,      ++i, 0, 1, 1);
    gl->addWidget(lineEdit_rotate_deg,   i,   1, 1, 1);
    gl->addWidget(label_rotate_deg_unit, i,   2, 1, 1);

    gl->addItem(vSpacer, ++i, 1, 1, 1);
}

void geomSetupRectangle::build()
{
    qDebug() << "== Rectangle build button pushed!" << Qt::endl;
}
